local qimou = fk.CreateSkill{
  name = "kl__qimou",
  tags = { Skill.Limited },
}


qimou:addEffect("active", {
  anim_type = "drawcard",
  prompt = "#kl__qimou",
  card_num = 0,
  target_num = 0,
  interaction = function(self, player)
    return UI.Spin {
      from = 1,
      to = player.hp,
    }
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(qimou.name, Player.HistoryGame) == 0 and player.hp > 0
  end,
  card_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = effect.from
    local tolose = self.interaction.data
    room:loseHp(player, tolose, qimou.name)
    if player.dead then return end
    room:addPlayerMark(player, "@kl__qimou-turn", tolose)
    player:drawCards(tolose, qimou.name)
    room:askToUseVirtualCard(player,{
      name = {"savage_assault","archery_attack"},
      skill_name = qimou.name,
      cancelable = false,
      extra_data = {
        bypass_times = true,
        extraUse = true,
      },
      prompt = "请视为使用一张【南蛮入侵】或【万箭齐发】",
    })
  end,
})

qimou:addEffect("targetmod", {
  residue_func = function(self, player, skill, scope)
    if skill.trueName == "slash_skill" and scope == Player.HistoryPhase then
      return player:getMark("@kl__qimou-turn")
    end
  end,
})

qimou:addEffect("distance", {
  correct_func = function(self, from, to)
    return -from:getMark("@kl__qimou-turn")
  end,
})

return qimou